package com.evidencer.demo.servlet;

import java.io.IOException;
import java.util.Date;
import java.util.Enumeration;

import javax.servlet.GenericServlet;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.annotation.WebServlet;

import com.evidencer.java.utils.Printer;

/**
 * @Title: GenericServletTest.java
 * @Package com.evidencer.demo.servlet
 * @Description: TODO
 * @author lyz lyzpoq_gmail_com
 * @date 2014/01/13 18:46:04
 * @version V1.0
 */
@WebServlet(name="GenericServletTest",urlPatterns="/GenericServletTest")
public class GenericServletTest extends GenericServlet {

	@Override
	public void service(ServletRequest req, ServletResponse res)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
		System.out.println("service...run...");
		Enumeration<String>  initParameterNames=this.getInitParameterNames();
		System.out.println("-------initParameterNames--------");
		while(initParameterNames.hasMoreElements()){
			System.out.println(initParameterNames.nextElement());
		}
		System.out.println("-------servletConfig--------");
		ServletConfig  servletConfig=this.getServletConfig();
		Printer.sop(servletConfig.getServletName(), "servletConfig.getServletName()");
		Printer.sop(servletConfig, "servletConfig");
		System.out.println("-------servletContext--------");
		ServletContext servletContext=servletConfig.getServletContext();
		Printer.sop(servletContext.toString(), "servletContext.toString()");
		Printer.sop(servletContext.getContextPath(), "servletContext.getContextPath()");
		Printer.sop(servletContext.getServerInfo(), "servletContext.getServerInfo()");
		Printer.sop(servletContext.getServletContextName(), "servletContext.getServletContextName()");
		System.out.println("-------this--------");
		Printer.sop(this.getServletInfo(), "this.getServletInfo()");
		Printer.sop(this.getServletName(), "this.getServletName()");
		System.out.println("-------ServletRequest--------");
		Printer.sop(req.getCharacterEncoding(), "req.getCharacterEncoding()");
		Printer.sop(req.getContentType(), "req.getContentType()");
		Printer.sop(req.getLocalAddr(), "req.getLocalAddr()");
		Printer.sop(req.getLocalName(), "req.getLocalName()");
		Printer.sop(req.getProtocol(), "req.getProtocol()");
		Printer.sop(req.getRemoteAddr(), "req.getRemoteAddr()");
		Printer.sop(req.getRemoteHost(), "req.getRemoteHost()");
		Printer.sop(req.getScheme(), "req.getScheme()");
		Printer.sop(req.getServerName(), "req.getServerName()");
		Printer.sop(req.getContentLength(), "req.getContentLength()");
		Printer.sop(req.getLocale(), "req.getLocale()");
		Printer.sop(req.getRemotePort(), "req.getRemotePort()");
		Printer.sop(req.getServerPort(), "req.getServerPort()");
		Printer.sop(new Date().toLocaleString());
		
		

	}

	/**
	*Title: init
	*Description: 
	* @throws ServletException
	* @see javax.servlet.GenericServlet#init()
	*/
	
	@Override
	public void init() throws ServletException {
		// TODO Auto-generated method stub
		super.init();
		System.out.println("init...run...");
	}
	
	

}

